package com.ruanjian.api.controller;

import com.ruanjian.api.bean.UserEarnings;
import com.ruanjian.api.utils.AjaxResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author shkstart
 * @create 2022-11-23 12:04
 */
@Api(tags = "用户收益接口")
@Slf4j
@RestController
@RequestMapping("/api/java/UserEarnings")
public class UserEarningsController extends BaseController{

    /**
     * 根据用户id获取用户收益信息
     * @param userId
     * @return
     */
    @CrossOrigin
    @GetMapping("/listUserEarningsByUserId/{userId}")
    public AjaxResult listUserEarningsByUserId(@PathVariable("userId") Long userId){
        return AjaxResult.success().add("UserEarnings", userEarningsService.listUserEarningsByUserId(userId));
    }

    /**
     * 根据用户id、阶段id、轮数id获取用户每轮收益
     * @param userEarnings 用户id、阶段id、轮数id
     * @return 用户收益信息
     */
    @CrossOrigin
    @PostMapping("/listUserEarningsSelective")
    public AjaxResult listUserEarningsSelective(@RequestBody UserEarnings userEarnings){
        return AjaxResult.success().add("EarningsSelective", userEarningsService.listUserEarningsSelective(userEarnings));
    }

    /**
     * 根据用户id和阶段id查询用户收益
     * @param userEarnings
     * @return
     */
    @CrossOrigin
    @PostMapping("/listUserEarningsByUserIdAndStageId")
    public AjaxResult listUserEarningsByUserIdAndStageId(@RequestBody UserEarnings userEarnings){
        return AjaxResult.success().add("EarningsByUserIdAndStageId",userEarningsService.listUserEarningsByUserIdAndStageId(userEarnings));
    }

}
